package org.mysfit.ctp4j.infra.enums;

import org.mysfit.ctp4j.infra.utils.TradeUtils;

/**
 * 开平标志类型
 * @author long.gf
 * @since 2022-12-08
 *
 */
public enum TFtdcOffsetFlagType {
	THOST_FTDC_OF_Open('0',"开仓"), 
	THOST_FTDC_OF_Close('1',"平仓"), 
	THOST_FTDC_OF_ForceClose('2',"强平"), 
	THOST_FTDC_OF_CloseToday('3',"平今"),
	THOST_FTDC_OF_CloseYesterday('4',"平昨"),
	THOST_FTDC_OF_ForceOff('5',"强减"),
	THOST_FTDC_OF_LocalForceClose('6',"本地强平"),
	;
	
	private TFtdcOffsetFlagType(Character value, String desc) {
		this.value = value;
		this.desc = desc;
	}
	
	private Character value;
	private String desc;

	public Character getValue() {
		return value;
	}
	
	public String getDesc() {
		return desc;
	}
	
	public static Character getTFtdcOffsetFlag(int kpFlag) {
		if(TradeUtils.isKC(kpFlag)) {
			return THOST_FTDC_OF_Open.getValue();
		}
		return THOST_FTDC_OF_Close.getValue();
	}

	public static String getStrTFtdcOffsetFlag(int kpFlag) {
		if(TradeUtils.isKC(kpFlag)) {
			return String.valueOf(THOST_FTDC_OF_Open.getValue());
		}
		return String.valueOf(THOST_FTDC_OF_Close.getValue());
	}
	
}
